package org.itboys.mobile.service.mysql.web;


import org.itboys.commons.ErrorException;
import org.itboys.commons.utils.tools.LongUtil;
import org.itboys.mobile.entity.mysql.TianJieWalletProduct;
import org.itboys.mobile.service.mongo.web.TianJieMemberService;
import org.itboys.mongodb.core.MongoDataSource;
import org.itboys.mongodb.service.BaseMongoService;
import org.itboys.mysql.service.BaseMySqlService;
import org.itboys.param.PageResult;
import org.itboys.param.ParamUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

/**
 * 作者：jiangxiong
 * 日期：2017年5月8日
 * 联系方式 ：empty90911@126.com
 * 描述：天街_金融_消费卡_产品_service
 */
@Service
public class TianJieWalletProductService extends BaseMySqlService<TianJieWalletProduct> {




    /**
     * 分页查询
     * @param request
     * @return
     */
    public PageResult<TianJieWalletProduct> selectProduct(HttpServletRequest request){
        Map<String,Object> param =ParamUtil.packageMongoExactParam(request,"type");
        return super.selectPage(param);
    }

    /**
     * 新增或保存
     * @param product
     */
    public void saveProduct(TianJieWalletProduct product){
        if(LongUtil.isNotZreo(product.getId())){
            super.update(product);
        }else{
            super.insert(product);
        }
    }
    /**
     * 删除
     * @param id
     */
    public void deleteProduct(Long id){
       // TianJieWalletProduct product = super.getById(id);
      super.delete(id);
    }

    /**
     * 单个查询
     * @param id
     * @return
     */
    public TianJieWalletProduct findOne(Long id){
        TianJieWalletProduct product=null;
        if(LongUtil.isNotZreo(id)){
            product=super.find(id);
        }else{
            product=new TianJieWalletProduct();
            product.setId(0l);
        }
        return product;
    }






}
